/**
 * 
 */
package ac.svn.accesscontrol.ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import ac.svn.accesscontrol.store.ISVNItem;
import ac.svn.accesscontrol.utils.Utility;

/**
 * @author Ankush
 *
 */
public class SimpleIconRenderer extends JLabel implements ListCellRenderer{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public SimpleIconRenderer(String rosourceUri){
		super("",JLabel.LEADING);
		setIcon(new ImageIcon(Utility.getImage(rosourceUri)));
		setOpaque(true);
	}
	
	
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		ISVNItem item = (ISVNItem) value;
		if(null != value)
		{
			setText(item.getName());
			setToolTipText(item.getTooltipText()); 
		}
		else
		{
			setText("...");
		}
		if(isSelected)
		{
			setBackground(new Color(104,204,255));
		}
		else
		{
			setBackground(Color.WHITE);
		}
		setForeground(Color.BLACK);
		
		return this;
	}

}
